const router = require('express').Router()
const validator = require('../middleware/validate')
const { articlealidator } = require('../model/article')
const auth = require('../middleware/auth')
const article = require('../controller/article')

// 获取全部
router.get('/', article.getAll)

// 获取指定某一个
router.get('/:aid', auth, article.get)

// 添加文章
router.post('/', [auth, validator(articlealidator)], article.create)

// 编辑某个文章
router.put('/:aid', [auth, validator(articlealidator)], article.update)

// 删除某个文章
router.delete('/:aid', auth, article.delete)

module.exports = router
